/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.extensoesSwing;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author Bone
 */
public class ExcluirFormButton extends PadraoFormButton{
    
    public ExcluirFormButton() {
        addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                getController().excluir();
            }
        });
        setText("Excluir");
        setPreferredSize(new Dimension(100, 45));
    }

    @Override
    public void setController(FormularioController controller) {
        super.setController(controller); //To change body of generated methods, choose Tools | Templates.
        if(controller == null){
            return;
        }
        if(controller.getJanela() == null){
            return;
        }
        if (controller.isPodeExcluir() && ((PadraoForm)controller.getJanela()).getAcao() == PadraoForm.ALTERAR) {
            setEnabled(true);
        }else{
            setEnabled(false);
        }
    }
    
}
